(function () {
  class WarningLineLayer extends BaseLayer {
    constructor(config = {}) {
      super(config);
      this.minZoom = 0
      this.maxZoom = 21
      this.name =  'WarningLineLayer'
      this.noneTips = true
      this.initLayer({
        type: 'line',
        'layout': {
          'line-join': ['get', 'lineJoin'],
          'line-cap': ['get', 'lineCap']
        },
        'paint': {
          'line-color': ['get', 'lineColor'],
          'line-width': ['get', 'lineWidth'],
          'line-dasharray': [5, 3]
        }
      })

    }

    getStyle(item) {
      item = Object.assign({}, item, {
        lineColor: item.lineColor || '#ff0000',
        lineWidth: item.lineWidth || 5,
      })
      return item
    }

    makeFeature(item) {
      item = this.getStyle(item)
      let f = {
        type: 'Feature',
        geometry: {
          type: 'LineString',
          coordinates: item.lineCoor
        },
        properties: {
          lineJoin: 'round',
          lineCap: 'round',
          ...item,
          data: item,
        }
      }
      return f
    }

    loadData() {
      this.cacheData = [
        {
          lineCoor: [
            [105, 0],
            [113, 4.5],
            [119, 11],
            [119, 18],
            [127, 22],
            [127, 34]
          ],
          lineWidth: 4,
          lineColor: '#f00',
          name: '24',
        },
        {
          lineCoor:[
            [105, 0],
            [120, 0],
            [132, 15],
            [132, 34]
          ],
          lineWidth: 4,
          lineColor: '#ff0',
          name: '48',
        },
      ]
      this.refreshLayer()
      this.fitExend()
    }
  }


  window.addEventListener('mapCreatedEvent', ev => {
    new WarningLineLayer({
      name: 'WarningLineLayer'
    })
  })
})();
